package cn.jtfadmin.core.modules.sys.controller;


import cn.jtfadmin.base.lang.common.domain.dto.PageRDTO;
import cn.jtfadmin.base.lang.common.domain.dto.ResultDTO;
import cn.jtfadmin.base.lang.common.domain.dto.SpecPagePDTO;
import cn.jtfadmin.base.lang.common.service.BaseService;
import cn.jtfadmin.core.modules.sys.domain.entity.SysLogEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 后管-系统日志controller
 *
 * @author jtf
 * @since 1.0
 */
@RestController
public class SysLogController {


    @Autowired
    private BaseService<SysLogEntity> sysLogService;


    /**
     * 分页查询系统日志
     *
     * @param sysLogPageQueryPDTO
     * @return
     */
    @RequestMapping(value = {"/sys/log/list"}, method = RequestMethod.GET)
    public ResultDTO<PageRDTO<SysLogEntity>> queryPageList(SpecPagePDTO<SysLogEntity> sysLogPageQueryPDTO) {
        return ResultDTO.successData(sysLogService.findAll(sysLogPageQueryPDTO));
    }

//    /**
//     * 清理logurl缓存信息
//     *
//     * @return
//     */
//    @PostMapping(value = "/sys/log/cleanUrlLogInfoCache")
//    public ResultDTO<String> cleanUrlLogInfoCache() {
//        sysLogService.cleanUrlLogInfoCache();
//        return ResultDTO.success();
//    }

    /**
     * 删除日志
     *
     * @param id 日志id
     * @return 操作结果
     */
    @DeleteMapping(value = "/sys/log/delete")
    public ResultDTO<String> delete(String id) {
        sysLogService.deleteById(id);
        return ResultDTO.success();
    }

    /**
     * 删除日志
     *
     * @param ids 日志id,...
     * @return 操作结果
     */
    @DeleteMapping(value = "/sys/log/deleteBatch")
    public ResultDTO<String> deleteBatch(String ids) {
        sysLogService.deleteBatch(ids);
        return ResultDTO.success();
    }
}
